package org.wzy.xmlg_backend.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.wzy.xmlg_backend.entity.Result;
import org.wzy.xmlg_backend.service.IEmpStatisticsService;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/emps/statistics")
@Tag(name = "EmpStatisticsController", description = "员工统计接口")
public class EmpStatisticsController {

    @Autowired
    private IEmpStatisticsService statisticsService;

    @GetMapping("/gender")
    @Operation(summary = "按性别统计")
    public Result<Map<String, Long>> genderStats() {
        return Result.success(statisticsService.countByGender());
    }

    @GetMapping("/job")
    @Operation(summary = "按职位统计")
    public Result<List<Map<String, Object>>> jobStats() {
        return Result.success(statisticsService.countByJob());
    }

    @GetMapping("/dept")
    @Operation(summary = "按部门统计")
    public Result<List<Map<String, Object>>> deptStats() {
        return Result.success(statisticsService.countByDept());
    }

    @GetMapping("/entry-year")
    @Operation(summary = "按入职年份统计")
    public Result<List<Map<String, Object>>> entryYearStats() {
        return Result.success(statisticsService.countByEntryYear());
    }
}